<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>活动编辑</title>
<%@include file="../include/include.jsp"%>
<%-- <link rel="stylesheet" type="text/css" href="${csspath }/public.css" />  --%>
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${layerPath }/layer.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
</head>
<style type="text/css"> 
/* 内部样式 */ 
html,body {
	font: 12px "Microsoft YaHei", "Microsoft YaHei", Verdana, Arial,
		sans-serif;
	color: #000;
	width:400px;
	height:400px;
}

.btn {
	/* width: 80px;
	height: 26px;
	color: #000;
	background-color: #ffffff;
	border: 1px solid #ADA9A4;
	cursor: pointer;
	border-radius:0px; */
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 0;
	font-size: 14px;
	font-weight: normal;
	line-height: 1.42857143;
	text-align: center;
	white-space: nowrap;
	vertical-align: middle;
	-ms-touch-action: manipulation;
	touch-action: manipulation;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	background-image: none;
	border: 1px solid transparent;
	border-radius: 0px;
	width: 80px;
	color: #fff;
	background-color: #5cb85c;
	border-color: #4cae4c;
}
</style> 

<script type="text/javascript">
function editCouponBatch(){
	$.ajax({
		type:'post',
		url: '${webcontext}/crmdp/dealer/coupon/editCouponBatch',
		data : $("form").serialize(),
		success : function(data) {
			if(data){
				window.parent.search();
				//parent.location.reload();
				//closeLayer();
			}else{
				return;
			}
		}
	});
}

function addGenerateItem(){
	$("form").attr('action','${webcontext}/crmdp/dealer/coupon/addGenerateCoupon');
	$("form").submit();
}

function deleteGenerateItem(id){
	$("form").attr('action','${webcontext}/crmdp/dealer/coupon/deleteGenerateCoupon?delLineId='+id);
	$("form").submit();
}

function closeLayer(){
	//当你在iframe页面关闭自身时
	//var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	//parent.layer.close(index); //再执行关闭 	
	window.parent.search();
}
</script>

<body>
<div id="content">
		<!-- wrap -->
		<div id="wrap">
		<form:form id="info_form" action="${webcontext}/crmdp/dealer/coupon/editCouponBatch" method="post" modelAttribute="dto">
		  <input type="hidden" name="couponBatchLine.couponBatch.id" value="${dto.id}">
		  <input type="hidden" name="id" value="${dto.id}">
		  <div class="data_div">
					<table class="table" style="width: 500px;margin-left: 100px;">
						<tr>
							<th width="30%" style="border-top: 0;">市场活动名称</th>
							<td width="70%" style="border-top: 0;">
							<input  class="text-left" type="hidden" name="batchName" value="${dto.batchName}">${dto.batchName}</td>
						</tr>
						<tr>
							<th width="30%" style="border-top: 0px solid #ddd;">活动说明</th>
							<td width="70%" style="border-top: 0;">
							<input class="text-left" name="description"  value="${dto.description}"></td>
						</tr>
						<tr>
							<th width="30%" style="border-top: 0px solid #ddd;">开始日期</th>
							<td width="70%" style="border-top: 0;">
							<input class="text-left" name="startDate" class="date" value="${dto.startDate}"></td>
						</tr>
						<tr>
							<th width="30%" style="border-top: 0px solid #ddd;">终止日期</th>
							<td width="70%" style="border-top: 0;">
							<input class="text-left" name="endDate" class="date" value="${dto.endDate}"></td>
						</tr>
							</table>
							</div>
							<div class="spliter h_10"></div>           
			     			 <div class="spliter h_5"></div> 
			     			 <font style="margin-left: 65px;">请选择优惠券：</font>
							<select name="couponBatchLine.ticket.id">
							<core:forEach items="${ticketMap}" var="map">
							<option value="${map.key}">${map.value}</option>
							</core:forEach>
							</select><a href="javascript:void(0)" onClick="addGenerateItem()">
								&nbsp;<i class="glyphicon glyphicon-plus"></i>
								</a>
							 <div class="spliter h_10"></div>           
			     			 <div class="spliter h_5"></div> 
  			<div class="data_div" style="width: 500px;">
				<table class="table" style="width: 500px;">
				<tr>
					<td width="80%" style="padding-left: 60px;">卡片名称</td>
					<td width="20%">操作</td>
				</tr>
				<core:forEach items="${batchLineList}" var="lineList">
				<tr>
					<td style="padding-left: 60px;">${lineList.ticket.ticketName}</td>
					<td><a href="javascript:void(0)" onClick="deleteGenerateItem('${lineList.id}')">删除</a></td>
					</tr>
				</core:forEach>
				</table>
				</div>
							
				<div  style="width:500px;height:50px;text-align: center">
					<button type="button" class="btn" onClick="editCouponBatch()" value="保存">
		                <i class="glyphicon glyphicon-ok" style="color:#FFFFFF"></i>&nbsp;保存
	                </button>
					<button type="button" class="btn" onClick="closeLayer()" value="取消">
		                <i class="glyphicon glyphicon-remove" style="color:#FFFFFF"></i>&nbsp;取消
	                </button>
        		</div>
		</form:form>
		</div>
            </div>
</body>
</html>